package cn.kilo.domain.support;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * @author kilok
 * 对于回调内容的处理
 */
public class HttpUtils {

    public static String readDate(HttpServletRequest request) throws IOException {
        BufferedReader reader=null;
        try{
            StringBuilder result=new StringBuilder();

            reader=request.getReader();
            for(String line;(line=reader.readLine())!=null;){
                if(0<result.length()){
                    //有内容就换行
                    result.append("\n");
                }
                result.append(line);
            }
            return result.toString();
        }catch (IOException e){
            throw new RuntimeException(e.getMessage());
        }finally {
            if(null!=reader){
                try {
                    reader.close();
                }catch (IOException e){
                    e.printStackTrace();
                }
            }
        }
    }
}
